const {Service}=require("egg")

class roleService extends Service{

    async index(){
        const sql=`select * from identity_authority`
        return await this.app.mysql.query(sql)
    }

    // 查看
    async show(id){
        const sql=`select * from identity_authority where type_id=?`
        return await this.app.mysql.query(sql,[id])
    }

    // 编辑
    async update(id,type_text,type_code){
        const sql=`update identity_authority set type_text=?,type_code=? where type_id=?`
        return await this.app.mysql.query(sql,[type_text,type_code,id])
    }

    // 删除
    async destroy(id){
        const sql=`DELETE FROM identity_authority WHERE type_id=?`
        return await this.app.mysql.query(sql,[id])
    }

    // 增加
    async create(id,type_text,type_code){
        const sql=`insert into identity_authority (type_id,type_text,type_code) values (?,?,?)`
        return await this.app.mysql.query(sql,[id,type_text,type_code])
    }
}

module.exports=roleService